######################################################## 
## Mod Title:   Last Visit Mod 
## Mod Version: 1.0.4 
## Author:       Niels Chr. Rd Denmark < ncr@db9.dk > 
## 
## Description:  This mod will enable users to see other users 
## last visit, the information are stored when they login, 
## after this mod, users can see when another user have last visited 
## the board, this is shown in the correspondings users profile. 
## This feture support, user level and hidden users 
## Admin will alway be able to se users last visit, regardless of the settings 
## if board config is "off", then only admin can see the information 
## if board is "on", then all users kan se other users last visit 
## ecxept hidden users, who always will be "hidden" 
## 
## This mod is only for phpBB2!! RC-4 
## 
## 
## Installation Level:  very Easy 
## Installation Time:   7-10 Minutes 
## Files To Edit:      6 
##   phpBB2/usercp_viewprofile.php 
##   phpBB2/includes/sessions.php 
##   phpBB2/includes/page_header.php 
##   phpBB2/templates/template_dirXX/index_body.tpl 
##   phpBB2/language/languageDirXX/lang_main.php 
##   phpBB2/templates/template_dirXX/profile_view_body.tpl    

######################################################## 
## 
## Installation Notes: 
## 
## Please also keep in mind, if you are using more than one language file or theme at your 
## site, you will need to edit the correct files for each occurrence.  Good Luck! 
######################################################## 

# 
#-----[ ACTION ]------------------------------------------ 
# 

SQL-query: 
ALTER TABLE users ADD user_lastlogon INT (11) DEFAULT '0' 

SQL-query: 
UPDATE users SET user_lastlogon=user_lastvisit 

SQL-query: 
INSERT INTO config (config_name, config_value) VALUES ('hidde_last_logon', '0') 

# 
#-----[ ACTION ]------------------------------------------ 
# 
#  OPEN FILE:  phpBB2/language/lang_XX/lang_main.php  (make sure to edit this file for every language your board uses). 
#  AT THE BOTTOM OF THE PAGE 

[FIND]: 
// 
// That's all Folks! 

[ADD BEFORE]: 
//add to last visit mod 
$lang['Last_logon'] = "Last Visit"; 
$lang['Hidde_last_logon'] = "Hidden"; 
$lang['Never_last_logon'] = "Never"; 
$lang['Users_today_explain'] = "The following %d users have visited the board today."; 
################################### This completes the changes in lang_main.php ############################## 

# 
#-----[ ACTION ]------------------------------------------ 
# 
#OPEN FILE:  phpBB2/includes/page_header.php 

[FIND]: 
$s_privmsg_new = 0; 
} 

[ADD AFTER]: 
//show dayly users mod 
$dato=create_date('mdY', time(),$board_config['board_timezone'] ); 
$timetoday=mktime(0,1,0,$dato[0].$dato[1],$dato[2].$dato[3],$dato[4].$dato[5].$dato[6].$dato[7]); 


$sql = 'SELECT user_id,username,user_allow_viewonline,user_level FROM ' . USERS_TABLE . ' WHERE user_lastlogon >= '.$timetoday.' AND user_lastlogon< '.($timetoday+86399).' ORDER BY username'; 
if (!$result = $db->sql_query($sql)) message_die(GENERAL_ERROR, "Couldn't retrieve user today data", "", __LINE__, __FILE__, $sql); 
while( $todayrow = $db->sql_fetchrow($result)) 
{ 
   $style_color = ""; 
   if( $todayrow['user_level'] == ADMIN ) 
   { 
      $todayrow['username'] = '<b>' . $todayrow['username'] . '</b>'; 
      $style_color = 'style="color:#' . $theme['fontcolor3'] . '"'; 
   } 
   else if( $todayrow['user_level'] == MOD ) 
   { 
      $todayrow['username'] = '<b>' . $todayrow['username'] . '</b>'; 
      $style_color = 'style="color:#' . $theme['fontcolor2'] . '"'; 
   } 
   $users_today_list.=($todayrow['user_allow_viewonline']) ? ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $todayrow['user_id']) . '"' . $style_color .'><b>' . $todayrow['username'] . '</b></a>':(($userdata[user_level]==ADMIN)?' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $todayrow['user_id']) . '"' . $style_color .'><i>' . $todayrow['username'] . '</i></a>':''); 
} 
$users_today=$db->sql_numrows($result); 

# 
#-----[ ACTION ]------------------------------------------ 
# 

[FIND]: 
"LAST_VISIT_DATE" => sprintf($lang['You_last_visit'], $s_last_visit), 
[ADD AFTER]: 
"USERS_TODAY_LIST" =>$users_today_list, 
"L_USERS_TODAY" =>sprintf($lang['Users_today_explain'],$users_today), 

################################### This completes the changes in page_header.php ############################## 


# 
#-----[ ACTION ]------------------------------------------ 
# 
## OPEN FILE:  phpBB2/includes/sessions.php 

[FIND]: 
if ( $user_id != ANONYMOUS ) 
   { 
      $sql = "UPDATE " . USERS_TABLE . " 
         SET user_session_time = $current_time, user_session_page = $page_id, user_lastvisit = $last_visit 

[REPLACE]: 
if ( $user_id != ANONYMOUS ) 
{ 
   $sql = "UPDATE " . USERS_TABLE . " 
   SET user_session_time = $current_time, user_session_page = $page_id, user_lastvisit = $last_visit, user_lastlogon = " . time() .  " 

################################### This completes the changes in sessions.php ############################## 

# 
#-----[ ACTION ]------------------------------------------ 
# 
## OPEN FILE:  phpBB2/usercp_viewprofile.php 

[FIND]: 
'JOINED' => create_date($lang['DATE_FORMAT'], $profiledata['user_regdate'], $board_config['board_timezone']), 

[ADD AFTER]: 
'L_LOGON' => $lang['Last_logon'], 
'LAST_LOGON' => ($userdata['user_level'] == ADMIN || (!$board_config['hidde_last_logon'] && $profiledata['user_allow_viewonline'])) ? (($profiledata['user_lastlogon'])? create_date($board_config['default_dateformat'], $profiledata['user_lastlogon'], $board_config['board_timezone']):$lang['Never_last_logon']):$lang['Hidde_last_logon'], 

################################### This completes the changes in usercp_viewprofile.php ############################## 

# 
#-----[ ACTION ]------------------------------------------ 
# 
#OPEN FILE:  phpBB2/templates/template_dirXX/index_body.tpl (make sure to edit this file for every theme you use). 

[FIND]: 
<tr> 
<td class="row1" align="center" valign="middle" rowspan="2"><img src="templates/subSilver/images/whosonline.gif" alt="{L_WHO_IS_ONLINE}" /></td> 
   <td class="row1" align="left" width="100%"><span class="gensmall">{TOTAL_POSTS}<br />{TOTAL_USERS}<br />{NEWEST_USER}</span> 
   </td> 
  </tr> 

[REPLACE WITH - other mods ?] 
[IF YOU HAVE BIRTHDAY MOD REPLACE WITH A VALUE OF 4 INSTEAD] 

<tr> 
   <td class="row1" align="center" valign="middle" rowspan="3"><img src="templates/subSilver/images/whosonline.gif" alt="{L_WHO_IS_ONLINE}" /></td> 
   <td class="row1" align="left" width="100%"><span class="gensmall">{TOTAL_POSTS}<br />{TOTAL_USERS}<br />{NEWEST_USER}</span> 
   </td> 
  </tr> 

  <tr> 
     <td class="row1" align="left"><span class="gensmall">{L_USERS_TODAY}<br />{USERS_TODAY_LIST}</span></td>    
  </tr> 
################################### This completes the changes in index_body.php ############################## 

# 
#-----[ ACTION ]------------------------------------------ 
# 
#OPEN FILE:  phpBB2/templates/template_dirXX/profile_view_body.tpl (make sure to edit this file for every theme you use). 

[FIND]: 
<tr> 
  <td valign="middle" align="right"><span class="gen">{L_JOINED}:&nbsp;</span></td> 
  <td width="100%"><b><span class="gen">{JOINED}</span></b></td> 
</tr> 

[ADD AFTER]: 

<tr> 
  <td valign="middle" align="right"><span class="gen">{L_LOGON}:&nbsp;</span></td> 
  <td width="100%"><b><span class="gen">{LAST_LOGON}</span></b></td> 
</tr> 

################################### This completes the changes in profile_view_body.tpl ############################## 


THAT'S IT!!  You're all done.  PART 1 

// EOF